package com.example.demo.mapper;

import com.example.demo.model.Follow;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface FollowMapper {
    @Select("SELECT * FROM follow WHERE followedId = #{followedId} AND followerId = #{followerId}")
    Follow selectOneFollow(Long followedId, Long followerId);

    @Select("SELECT * FROM follow WHERE followedId = #{followedId}")
    List<Follow> selectFollowers(Long followerId);

    @Select("SELECT * FROM follow WHERE followerId = #{followerId}")
    List<Follow> selectFollowings(Long followedId);

    @Insert("INSERT INTO follow (followedId, followerId) VALUES (#{followedId}, #{followerId})")
    void insertFollow(Long followedId, Long followerId);

    @Insert("DELETE FROM follow WHERE followedId = #{followedId} AND followerId = #{followerId}")
    void deleteFollow(Long followedId, Long followerId);
}
